from selenium.webdriver.common.by import By
from base.base_action import BaseAction


# 课程标签页面
class CourseLabelPage(BaseAction):

    # 课程标签按钮
    course_label_btn = By.XPATH, "//span[text()='课程标签']"

    # 新建标签按钮
    add_label_btn = By.XPATH, "//span[text()='新建标签']"

    # 标签分类输入框
    label_sort_input = By.XPATH, "//input[@placeholder='请选择标签分类']"

    # 选择标签分类
    select_label_sort = "document.getElementsByClassName('el-select-dropdown__item')[8].click();"

    # 标签名称输入框
    label_name_input = By.XPATH, "//input[@placeholder='请输入标签名称']"

    # 确定按钮
    determine_btn = "document.getElementsByClassName('el-button el-button--primary')[3].click();"

    # 禁用按钮
    disable_btn = "document.getElementsByClassName('operate-style')[1].click();"

    # 标签删除按钮
    remove_label_btn = "document.getElementsByClassName('operate-style')[2].click();"

    # 点击删除弹窗的确定按钮
    determine1_btn = By.XPATH, "/html/body/div[2]/div/div[3]/button[2]"

    # 点击课程标签按钮
    def click_course_label_btn(self):
        return self.click(self.course_label_btn)

    # 点击新建标签
    def click_add_label_btn(self):
        return self.click(self.add_label_btn)

    # 点击标签分类输入框
    def select_label_sort_input(self):
        return self.click(self.label_sort_input)

    # 选择标签分类
    def click_select_label_sort(self):
        return self.execute_js(self.select_label_sort)

    # 输入标签名称
    def input_label_name(self, content):
        return self.input(self.label_name_input, content)

    # 点击确定
    def click_determine_btn(self):
        return self.execute_js(self.determine_btn)

    # 点击禁用标签
    def click_disable_label(self):
        return self.execute_js(self.disable_btn)

    # 点击确定
    def click_determine1_btn(self):
        return self.click(self.determine1_btn)

    # 点击删除
    def click_remove_label_btn(self):
        return self.execute_js(self.remove_label_btn)

